#! /bin/bash

str="helloworld"

echo ${str:0:5} #hello
echo ${str:5:2} #wo
echo ${str:5} #world
echo ${str: -2} #ld

echo "strlen = ${#str}"


arr=(11 22 33 44 55 [10]=66)
echo ${arr[0]} #11
echo ${arr[1]} #22
echo ${arr[2]} #33
echo ${arr[3]} #44
echo ${arr[4]} #55
echo ${arr[10]} #66

echo "========="
echo ${arr[@]} #11 22 33 44 55 66
echo ${arr[*]} #11 22 33 44 55 66
echo ${#arr[@]} #6
echo ${#arr[*]} #6

arr1=("a" "b" "c" "d" "e" "f")
echo ${arr1[@]} #a b c d e f

arr2=(${arr[*]} ${arr1[*]})
echo ${arr2[@]} #11 22 33 44 55 66 a b c d e f

# 多行注释   头尾取相同字符
<<!
echo "======="
echo "hello world"
echo "======="
!

<< XXX
echo "======="
echo "hello world"
echo "======="
XXX

#shell 交互
read -p "请输入一个字符串：" val1 val2 val3
echo $val1 $val2 $val3

read -p "input data:" name age class
echo "name: $name age: $age class: $class"